package com.southwind.phone_store_demo.repository;

import com.southwind.phone_store_demo.entity.PhoneInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PhoneInfoRepository extends JpaRepository<PhoneInfo,Integer> {
    public List<PhoneInfo> findAllByCategoryType(Integer categoryType);

//    @Select("select * from phone_info where category_type = #{categoryType} limit 0,2")
@Query(value = "select * from phone_info where category_type = :categoryType limit 0,2",nativeQuery = true)

public List<PhoneInfo> selectByCategoryType(Integer categoryType);
}
